from django.core.exceptions import ObjectDoesNotExist
from django_filters.rest_framework import DjangoFilterBackend
from rest_framework.decorators import action
from rest_framework.filters import SearchFilter, OrderingFilter
from rest_framework.permissions import IsAuthenticated

from backend import helper
from tag.filter import TagsFilter
from tag.models import Tags
from tag.serializers import TagsSerializer


class TagViewSet(helper.MyModelViewSet):
    queryset = Tags.objects.all().order_by('-clout')
    serializer_class = TagsSerializer
    filter_class = TagsFilter
    filter_backends = [DjangoFilterBackend, SearchFilter, OrderingFilter]
    ordering_fields = ['clout']
    search_fields = ['name']
